<extend name="Public/base"/>

<block name="body">
<!-- 标题栏 -->
  <div class="main-title">
    <h2>{$meta_title}</h2>
  </div>
  <div class="cf">
    <span class="text-danger">
      （修改店铺所在地时,商户每个月只能申请一次修改店铺地址）<br/>
      具体操作步骤：<br/>
                    1、可直接进行修改，然后点击申请；<br/>
                    2、通过百度地图进行搜索：<br/>&nbsp;&nbsp;&nbsp;
                      1）、可选择城市，再进行具体地址搜索，然后点击搜索一下；<br/>&nbsp;&nbsp;&nbsp;
                      2）、搜索的数据会显示在地图上；<br/>&nbsp;&nbsp;&nbsp;
                      3）、点击地图上显示的方位，会将具体地址写入到店铺详细地址输入框<br/>
        （注意：如果通过地图选择这种方式，原地址所在省市区发生变化，需手动修改店铺所在地省市区）
    </span>
  </div>
<link rel="stylesheet" type="text/css" href="__CSS__/store.css?15031711">
<form action="{:U()}" method="post" class="form-horizontal">
  <table border="0" cellpadding="0" cellspacing="0" class="store-joinin" style="width:920px">
    <thead>
      <tr>
        <th colspan="40">店铺详细地址信息</th>
      </tr>
    </thead>
    <tbody>
      <tr style="background: rgb(255, 255, 255);">
        <th style="width:173px">店铺所在地：</th>
        <!-- <td><input type="text" name="address" value="{$data.address}" <if condition="$status neq 3"> readonly </if> /></td> -->
        <td>{:Hook('areaSelect',array('province'=>$arr['province'],'city'=>$arr['city'],'district'=>$arr['district'] ))}</td>
        <th style="width:173px">店铺详细地址：</th>
        <td colspan="20"><input type="text" name="address_detail" value="{$data.address_info}" readonly style="min-width:200px" /></td>
      </tr>
      <if condition="$status neq 3">
        <tr>
          <th style="width:173px">修改后店铺地址：</th>
          <td>{$info.address}</td>
          <th style="width:173px">修改后店铺详细地址：</th>
          <td colspan="20">{$info.address_detail}</td>
        </tr>
        </if>
      <tr>
        <td colspan="40" style="text-align:center">

          <switch name="status">
            <case value="0"><button class="btn submit-btn ajax-post" type="button" target-form="form-horizontal">平台审核中</button></case>
            <case value="1"><button class="btn ajax-post" type="button" target-form="form-horizontal">审核通过</button></case>
            <case value="-1">
              <button class="btn submit-btn ajax-post" type="button" target-form="form-horizontal">审核未通过</button>
              <button class="btn submit-btn ajax-post" type="submit" target-form="form-horizontal">继续申请</button>
            </case>
            <case value="3"><button class="btn submit-btn ajax-post" type="submit" target-form="form-horizontal">申请</button></case>
          </switch>
                
        </td>
      </tr>
    </tbody>
  </table>
</form>
  <table border="0" cellpadding="0" cellspacing="0" style="width:920px">
    <tbody>
      <tr>
        <td><div class="mapbox" id="searchBox" style="width:100% ; position: relative"></div></td>
      </tr>
      <tr>
        <td><div class="mapbox" id="allmap" style="height:500px;width:100%"></div></td>
      </tr>
    </tbody>
  </table> 
</block>

<block name="script">
<script src="http://api.map.baidu.com/api?v=2.0&ak=iToiAqxiGgBGr2rmmFiXjmSHIQRr3zRk"></script>
<script type="text/javascript" src="__JS__/lib/bd0.js" ></script>
<!-- <script type="text/javascript" src="http://api.map.baidu.com/library/SearchControl/1.4/src/SearchControl_min.js"></script> -->
<link rel="stylesheet" href="http://api.map.baidu.com/library/SearchControl/1.4/src/SearchControl_min.css" />
<link rel="stylesheet" type="text/css" href="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.css" />
<script src="__JS__/lib/bd.js" ></script>
<!-- <script type="text/javascript" src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> -->
  <script type="text/javascript">
    //导航高亮
    highlight_subnav("{:U('Store/editAddress')}");
    //地图控件
    var map = new BMap.Map("allmap");
        map.centerAndZoom(new BMap.Point("{$latlng.lng}","{$latlng.lat}"),16);
        map.enableScrollWheelZoom(true);
    var new_point = new BMap.Point("{$latlng.lng}","{$latlng.lat}");
    var myIcon = new BMap.Icon('http://api0.map.bdimg.com/images/marker_red_sprite.png',new BMap.Size(40,24));
    var marker = new BMap.Marker(new_point,{icon:myIcon});  // 创建标注
        map.addOverlay(marker);               // 将标注添加到地图中
        map.centerAndZoom(new_point, 11);     // 地图显示级别
        marker.enableDragging();              // 标记点可拖拽
        map.addEventListener("click", showInfo);//点击显示文字图层
    // 添加定位控件
    var geoCtrl = new BMap.GeolocationControl({
        showAddressBar       : true //是否显示
        , enableAutoLocation : false //首次是否进行自动定位
        , offset             : new BMap.Size(0,25) 
        //, locationIcon     : icon //定位的icon图标
    });
    // 将定位控件添加到地图
    map.addControl(geoCtrl);
    var _status = "{$status}";
    if(_status == -1 || _status == 3){
      //检索类型
      var type = "";
      type = LOCAL_SEARCH ;   //周边检索
      //type = TRANSIT_ROUTE; //公交检索
      //type = DRIVING_ROUTE; //驾车检索

      //创建检索控件
      var searchControl = new BMapLib.SearchControl({
          container : "searchBox" //存放检索控件的容器
          , map     : map          //检索的关联地图
          , type    : type        //检索类型
      });
      $('#BMapLib_sc_b0').html('点击搜索');
      $('.BMap_cpyCtrl').css({'display':'none'});/*隐藏百度地图版权*/
      $('#BMapLib_scroll').parent().css({"width":"205px","left":"15%"});
    }
    
    //地图控件 自定义函数
    function showInfo(e){
        var lng = e.point.lng;
        var lat = e.point.lat;
        $.ajax({
          url:"{:U('Store/getAddresInfoByLngLat')}",
          data:{lat:lat,lng:lng},
          dataType:'json',
          type:'post',
          success: function(res){
            //console.log(res);
            $('input[name=address_detail]').val(res);
            $('#BMapLib_PoiSearch').val(res);
          }
        });
        //UI.confirm(lng+','+lat);
    }
  </script>
</block>